package com.lin.cms.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.lin.cms.domain.Site;

public class SiteValidator implements Validator {

	@SuppressWarnings("unchecked")
	public boolean supports(Class clazz) {
		return Site.class.isAssignableFrom(clazz);
	}

	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "siteId", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "configId", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "domain", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "sitePath", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "siteName", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "shortName", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "protocol", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dynamicSuffix", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "staticSuffix", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "isIndexToRoot", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "isStaticIndex", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localeAdmin", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localeFront", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "tplSolution", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "finalStep", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "afterCheck", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "isRelativePath", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "isRecycleOn", "required");
	}

}
